﻿using Redbus.Events;

namespace JunionRobotTaskManager.Models
{

    /// <summary>
    /// 信息中心
    /// </summary>
    public class BusMessage: EventBase
    {
      
        public BusMessage(string key, Operation action, object data) : base()
            {
                this.Key = key;
                this.Data = data;
                this.Action = action;
            }

        /// <summary>
        /// 操作方法
        /// </summary>
        public Operation Action { get; set; }

        /// <summary>
        /// 键
        /// </summary>
        public string Key { get; set; }

        /// <summary>
        /// 信息
        /// </summary>
        public object Data { get; set; }

        /// <summary>
        /// 添加信息 
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="data">信息</param>
        /// <returns></returns>
        public static BusMessage AddCreate(string key,object data)
        {
            return new BusMessage(key, Operation.Add, data);
        }

        /// <summary>
        /// 删除信息 
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="data">信息</param>
        /// <returns></returns>
        public static BusMessage DeleteCreate(string key, object data)
        {
            return new BusMessage(key, Operation.Delete, data);
        }

        /// <summary>
        /// 修改信息 
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="data">信息</param>
        /// <returns></returns>
        public static BusMessage UpdateCreate(string key, object data)
        {
            return new BusMessage(key, Operation.Update, data);
        }

    }

    public enum Operation
    {
        Add,
        Update,
        Delete,
    }
}
